Hi everyone, below code was supposed to be comparing two given arrays. Not to cause too much mess, for the time being i sent you only the problematic part. these two arrays are sorted alphabetically and they are string arrays. When the loop arrives at i = 20, it detects the first mismatching value between two arrays, and thus it should assign this value to w1[0], and at at i = 22 it redetects that there is a matching value. Then it should assign this value to normally to z120 since the code detects two mismatching values consecutively.
for(i=0; i< noOfAttrs1; i++) {
string a1 = attrNames1[i]
string x1 = attrNames4[i - oFFsetN]
// print a1 "\t i'm the first baseline's attributes\t" x1 "\t i'm the second baseline's attributes\n"
if(x1 == a1) {
z1[sizer1++] = a1
print z1[i] "\n"
}
if(x1 != a1) {
w1[sizer2++] = attrNames1[i]
//oFFsetP++
oFFsetN++
// print w1[i] "\n"
}
}
SystemAdmin - Thu May 14 04:19:46 EDT 2009 |
Re: Comparing two string arrays ??? |
Re: Comparing two string arrays ???
Yes, looks like you want to print z1 of sizer1, not of i. Or just print a1. I would probably print i, sizer1, and a1.
do while (!Done)
} if (i1 >= Size1) Done = true
elseif(i4 >= Size4) Done = true
else
{ a1 = attrNames1[i1]
a4 = attrNames4[i4]
if (a1 < a4) Deal with mismatch, i1++
elseif(a1 > a4) Deal with mismatch, i4++
else They are the same; i1++; i4++
}
}
|